import QtQuick 1.0
import com.nokia.symbian 1.0
import Qt.labs.components.native 1.0

Rectangle{

    property int viewWidth: 640
    property int viewHeight: 360
    property real bgOpacity: 0.6
    property color bgColor: "#F7F7F7"

    function getDayName(timestamp){
        var date = new Date(timestamp);
        var dayIndex = date.getDay();
        var dayName = daysList(dayIndex);
        return dayName;
    }

    function daysList(index){
        var daysListArray = new Array();
        daysListArray[0] = qsTr("Monday");
        daysListArray[1] = qsTr("Tuesday");
        daysListArray[2] = qsTr("Wednesday");
        daysListArray[3] = qsTr("Thursday");
        daysListArray[4] = qsTr("Friday");
        daysListArray[5] = qsTr("Saturday");
        daysListArray[6] = qsTr("Sunday");
        return daysListArray[index];
    }

    Rectangle{
        id: bgRect
        width: viewWidth
        height: viewHeight
        opacity: bgOpacity
        color: bgColor
        border.color: "grey"
        border.width: 2
        Behavior on opacity { NumberAnimation{ duration: 200 } }
    }

    ListView{
        id: menuListView
        anchors.fill: bgRect
        clip: true
        model: menuModel
        orientation: ListView.Horizontal
        snapMode: ListView.SnapOneItem
        width: parent.width
        spacing: 20
        delegate: Rectangle{
            width: childrenRect.width
            Text{
                id: dayElement
                text: getDayName(timestamp)
            }
            Text{
                id: breakfastElement
                text: breakfast
                anchors.top: dayElement.bottom
            }
            Text{
                id: dinnerElement
                text: dinner
                anchors.top: breakfastElement.bottom
            }
            Text{
                id: mealElement
                text: meal
                anchors.top: dinnerElement.bottom
            }
            Text{
                id: lunchElement
                text: lunch
                anchors.top: mealElement.bottom
            }
            Text{
                id: supperElement
                text: supper
                anchors.top: lunchElement.bottom
            }
        }

    }

    ListModel{
        id: menuModel
        ListElement{
            timestamp: 1317811780000
            breakfast: "Puuro"
            dinner: "Jauhelihakastike"
            meal: "Muroja"
            lunch: "Katkarapukastike"
            supper: "Jauhelihakastike"
        }
        ListElement{
            timestamp: 1317815380000
            breakfast: "Puuro"
            dinner: "Jauhelihakastike"
            meal: "Muroja"
            lunch: "Katkarapukastike"
            supper: "Jauhelihakastike"
        }
        ListElement{
            timestamp: 1317815380000
            breakfast: "Puuro"
            dinner: "Jauhelihakastike"
            meal: "Muroja"
            lunch: "Katkarapukastike"
            supper: "Jauhelihakastike"
        }
        ListElement{
            timestamp: 1317815380000
            breakfast: "Puuro"
            dinner: "Jauhelihakastike"
            meal: "Muroja"
            lunch: "Katkarapukastike"
            supper: "Jauhelihakastike"
        }
    }

}
